﻿function killVerification()
{
	var Who = 0;
	for(i = 0; i < document.formSaisie.B1.length; i++){
		if(document.formSaisie.B1[i].checked)
		{
			Who = document.formSaisie.B1[i].value;
		}
	}
	var VictimSteamID = document.formSaisie.killVictimSteamIDText.value;
	var AttackSteamID = document.formSaisie.killAttackSteamIDText.value;
	var AssistSteamID = document.formSaisie.killAssistSteamIDText.value;
	var Weapon = document.formSaisie.killWeapon.value;
	var Map = document.formSaisie.killMap.value;
	var VictimClass = document.formSaisie.killVictimclass.value;
	var AttackClass = document.formSaisie.killAttackclass.value;
	var AssistClass = document.formSaisie.killAssistclass.value;
	var Critz ="";
	for(i = 0; i < document.formSaisie.B4.length; i++){
		if(document.formSaisie.B4[i].checked)
		{
			Critz = document.formSaisie.B4[i].value;
		}
	}
	var Domination ="";
	for(i = 0; i < document.formSaisie.B8.length; i++){
		if(document.formSaisie.B8[i].checked)
		{
			Domination = document.formSaisie.B8[i].value;
		}
	}
	
	var Revenge ="";
	for(i = 0; i < document.formSaisie.B9.length; i++){
		if(document.formSaisie.B9[i].checked)
		{
			Revenge = document.formSaisie.B9[i].value;
		}
	}
	
	var Headshot ="";
	for(i = 0; i < document.formSaisie.B10.length; i++){
		if(document.formSaisie.B10[i].checked)
		{
			Headshot = document.formSaisie.B10[i].value;
		}
	}
	
	var Backstab ="";
	for(i = 0; i < document.formSaisie.B11.length; i++){
		if(document.formSaisie.B11[i].checked)
		{
			Backstab = document.formSaisie.B11[i].value;
		}
	}
	
	var deadringer ="";
	for(i = 0; i < document.formSaisie.B12.length; i++){
		if(document.formSaisie.B12[i].checked)
		{
			deadringer = document.formSaisie.B12[i].value;
		}
	}
	
	var Amount = document.formSaisie.killAmount.value;
	var error = 0;
		if(Who == "" || Who == 0) {
		error = 1;
	}
	if(isNaN(Amount))
	{
		error = 2;
	}
	else
	{
		if(Amount<1)
		{
			error = 2;
		}
	}
	if(Critz == "") {
		error = 3;
	}
	
	if(Domination == "") {
		error = 4;
	}
	
	if(Revenge == "") {
		error = 5;
	}
	
	if(Headshot == "") {
		error = 6;
	}
	
	if(Backstab == "") {
		error = 7;
	}
	
	if(deadringer == "") {
		error = 8;
	}
	return error;
}

function showCritz()
{
	document.getElementById("cacheCritz").style.display = "block";
	for(i = 0; i < document.formSaisie.B4.length; i++){
		if(document.formSaisie.B4[i].checked)
		{
			if(document.formSaisie.B4[i].value == 0 || document.formSaisie.B4[i].value == -1)
				document.formSaisie.B4[i].checked = false;
		}
	}
}

function cacheCritz()
{
	document.getElementById("cacheCritz").style.display = "none";
}

function hurtVerification()
{
	var error = 0;
	var Amount = document.formSaisie.HurtAmount.value;
	if(isNaN(Amount))
	{
		error = 2;
	}
	else
	{
		if(Amount<1)
		{
			error = 2;
		}
	}
	
	var Who = 0;
	for(i = 0; i < document.formSaisie.HurtB1.length; i++){
		if(document.formSaisie.HurtB1[i].checked)
		{
			Who = document.formSaisie.HurtB1[i].value;
		}
	}
	if(Who == "" || Who == 0) {
		error = 21;
	}
	
	var Critz = "";
	for(i = 0; i < document.formSaisie.HurtB4.length; i++){
		if(document.formSaisie.HurtB4[i].checked)
		{
			Critz = document.formSaisie.HurtB4[i].value;
		}
	}
	if(Critz == "") {
		error = 22;
	}
	
	var SelfDomg = "";
	for(i = 0; i < document.formSaisie.HurtB5.length; i++){
		if(document.formSaisie.HurtB5[i].checked)
		{
			SelfDomg = document.formSaisie.HurtB5[i].value;
		}
	}
	if(SelfDomg == "") {
		error = 23;
	}
	
	return error;
}

function engiVerification()
{
	var error = 0;
	var Amount = document.formSaisie.engineerAmount.value;
	if(isNaN(Amount))
	{
		error = 2;
	}	
	else
	{
		if(Amount<1)
		{
			error = 2;
		}
	}
	var What = 0;
	for(i = 0; i < document.formSaisie.engineerChoose.length; i++){
		if(document.formSaisie.engineerChoose[i].checked)
		{
			What = document.formSaisie.engineerChoose[i].value;
		}
	}
	if(What == "" || What == 0) {
		error = 31;
	}
	
	if(What == "build")
	{
		var WhatObject = 0;
		for(i = 0; i < document.formSaisie.engineerobjectname.length; i++){
			if(document.formSaisie.engineerobjectname[i].checked)
			{
				WhatObject = document.formSaisie.engineerobjectname[i].value;
			}
		}
		if(WhatObject == "" || WhatObject == 0) {
			error = 31;
		}
	}
	else
	{
		if(What == "teleport")
		{
			var Who = 0;
			for(i = 0; i < document.formSaisie.engineerdetroy.length; i++){
				if(document.formSaisie.engineerdetroy[i].checked)
				{
					Who = document.formSaisie.engineerdetroy[i].value;
				}
			}
			if(Who == "" || Who == 0) {
				error = 32;
			}
		}
	}
	return error;
}

function heavyVerification()
{
	var error = 0;
	var Amount = document.formSaisie.heavyAmount.value;
	if(isNaN(Amount))
	{
		error = 2;
	}
	else
	{
		if(Amount<1)
		{
			error = 2;
		}
	}
	var What = 0;
	for(i = 0; i < document.formSaisie.heavysandwitch.length; i++){
		if(document.formSaisie.heavysandwitch[i].checked)
		{
			What = document.formSaisie.heavysandwitch[i].value;
		}
	}
	if(What == "" || What == 0) {
		error = 41;
	}
	
	if(What == "other")
	{
		var Who = 0;
		for(i = 0; i < document.formSaisie.heavysandwitchvicattack.length; i++){
			if(document.formSaisie.heavysandwitchvicattack[i].checked)
			{
				Who = document.formSaisie.heavysandwitchvicattack[i].value;
			}
		}
		if(Who == "" || Who == 0) {
			error = 42;
		}
	}
	
	return error;
}
function sniperVerification()
{
	var error = 0;
	var Amount = document.formSaisie.sniperAmount.value;
	if(isNaN(Amount))
	{
		error = 2;
	}
	else
	{
		if(Amount<1)
		{
			error = 2;
		}
	}
	
	var What = 0;
	for(i = 0; i < document.formSaisie.sniperJarateRazor.length; i++){
		if(document.formSaisie.sniperJarateRazor[i].checked)
		{
			What = document.formSaisie.sniperJarateRazor[i].value;
		}
	}
	if(What == "" || What == 0) {
		error = 51;
	}
	
	var Who = 0;
	for(i = 0; i < document.formSaisie.sniperAttackVictim.length; i++){
		if(document.formSaisie.sniperAttackVictim[i].checked)
		{
			Who = document.formSaisie.sniperAttackVictim[i].value;
		}
	}
	if(Who == "" || Who == 0) {
		error = 52;
	}

	
	return error;
}

function medicVerification()
{
	var error = 0;
	var Amount = document.formSaisie.MedicAmount.value;
	if(isNaN(Amount))
	{
		error = 2;
	}
	else
	{
		if(Amount<1)
		{
			error = 2;
		}
	}
	
	var What = 0;
	for(i = 0; i < document.formSaisie.uberGroup.length; i++){
		if(document.formSaisie.uberGroup[i].checked)
		{
			What = document.formSaisie.uberGroup[i].value;
		}
	}
	if(What == "" || What == 0) {
		error = 62;
	}
	
	var Who = 0;
	for(i = 0; i < document.formSaisie.medicwho.length; i++){
		if(document.formSaisie.medicwho[i].checked)
		{
			Who = document.formSaisie.medicwho[i].value;
		}
	}
	if(Who == "" || Who == 0) {
		error = 61;
	}
	return error;
}

function scoutVerification()
{
	var error = 0;
	var Amount = document.formSaisie.ScoutAmount.value;
	if(isNaN(Amount))
	{
		error = 2;
	}
	else
	{
		if(Amount<1)
		{
			error = 2;
		}
	}
	
	var What = 0;
	for(i = 0; i < document.formSaisie.scoutAchievements.length; i++){
		if(document.formSaisie.scoutAchievements[i].checked)
		{
			What = document.formSaisie.scoutAchievements[i].value;
		}
	}
	if(What == "" || What == 0) {
		error = 71;
	}
	
	if(What=="stunt")
	{
		var Who = "";
		for(i = 0; i < document.formSaisie.scoutAchievementsStunt.length; i++){
			if(document.formSaisie.scoutAchievementsStunt[i].checked)
			{
				Who = document.formSaisie.scoutAchievementsStunt[i].value;
			}
		}
		if(Who == "") {
			error = 72;
		}
	}
	
	return error;
}

function funVerification()
{
	var error = 0;
	var Amount = document.formSaisie.funAmount.value;
	if(isNaN(Amount))
	{
		error = 2;
	}
	else
	{
		if(Amount<1)
		{
			error = 2;
		}
	}
	var What = 0;
	for(i = 0; i < document.formSaisie.funradio.length; i++){
		if(document.formSaisie.funradio[i].checked)
		{
			What = document.formSaisie.funradio[i].value;
		}
	}
	if(What == "" || What == 0) {
		error = 81;
	}
	if(What == "1")
	{
		var funText = document.formSaisie.funtext.value;
		alert(funText);
		if(funText == "") {
			error = 82;
		}
		var Exact = "";
		for(i = 0; i < document.formSaisie.funradioexact.length; i++){
			if(document.formSaisie.funradioexact[i].checked)
			{
				Exact = document.formSaisie.funradioexact[i].value;
			}
		}
		if(Exact == "") {
			error = 83;
		}
	}
	return error;
}

function conditionVerification()
{
	var error = 0;
	var Who = 0;
	for(i = 0; i < document.formSaisie.B1Condition.length; i++){
		if(document.formSaisie.B1Condition[i].checked)
		{
			Who = document.formSaisie.B1Condition[i].value;
		}
	}
	
	var Condition = 0;
	for(i = 0; i < document.formSaisie.B2Conditon.length; i++){
		if(document.formSaisie.B2Conditon[i].checked)
		{
			Condition = document.formSaisie.B2Conditon[i].value;
		}
	}
	
	if(Who == "" || Who == 0) {
		error = 91;
	}
	
	if(Condition == "" || Condition == 0) {
		error = 92;
	}
	else
	{
		if( Condition == "1" )
		{
			var B2ConditonHealth1 = document.formSaisie.B2ConditonHealth1.value;
			var B2ConditonHealth2 = document.formSaisie.B2ConditonHealth2.value;
			if(isNaN(B2ConditonHealth1) || B2ConditonHealth1 =="" || B2ConditonHealth1 == 0)
			{
				error = 93;
			}
			else
			{
				if(B2ConditonHealth1 < 0 || B2ConditonHealth1> 450)
				{
					error = 93;
				}
			}
			
			if(isNaN(B2ConditonHealth2) || B2ConditonHealth2 == "" || B2ConditonHealth2 == 0)
			{
				error = 94;
			}
			else
			{
				if(B2ConditonHealth2 < 0 || B2ConditonHealth2 > 450 || B2ConditonHealth1 > B2ConditonHealth2)
				{
					error = 94;
				}
			}
		}
		else
		{
			if( Condition == "3" )
			{
				var B2ConditonChapeau = document.formSaisie.B2ConditonChapeau.value;
				if(isNaN(B2ConditonChapeau))
				{
					error = 95;
				}
			}
			else
			{
				if( Condition == "2" )
				{
					var B2ConditonDistance1 = document.formSaisie.B2ConditonDistance1.value;
					var B2ConditonDistance2 = document.formSaisie.B2ConditonDistance2.value;
					if(isNaN(B2ConditonDistance1) || B2ConditonDistance1 =="" || B2ConditonDistance1 < 0)
					{
						error = 96;
					}
					if(isNaN(B2ConditonDistance2) || B2ConditonDistance2 == "" || B2ConditonDistance2 < 0)
					{
						error = 97;
					}
					else
					{
						if(B2ConditonDistance2<B2ConditonDistance1)
						{
							error = 97;
						}
					}
				}
			}
		}
	}
	return error;
}
function mapVerification()
{
	var error = 0;
	var Amount = document.formSaisie.MapAmount.value;
	if(isNaN(Amount))
	{
		error = 2;
	}
	else
	{
		if(Amount<1)
		{
			error = 2;
		}
	}
	return error;
}

function demomanVerification()
{
	var error = 0;
	var Amount = document.formSaisie.demomanAmount.value;
	if(isNaN(Amount))
	{
		error = 2;
	}
	else
	{
		if(Amount<1)
		{
			error = 2;
		}
	}
	return error;
}

function soldierVerification()
{
	var error = 0;
	var Amount = document.formSaisie.soldierAmount.value;
	if(isNaN(Amount))
	{
		error = 2;
	}
	else
	{
		if(Amount<1)
		{
			error = 2;
		}
	}
	var Action = 0;
	for(i = 0; i < document.formSaisie.soldieraction.length; i++){
		if(document.formSaisie.soldieraction[i].checked)
		{
			Action = document.formSaisie.soldieraction[i].value;
		}
	}
	if(Action == 0)
	{
		error = 111;
	}
	return error;
}

function spyVerification()
{
	var error = 0;
	var Amount = document.formSaisie.spyAmount.value;
	if(isNaN(Amount))
	{
		error = 2;
	}
	else
	{
		if(Amount<1)
		{
			error = 2;
		}
	}
	var Action = 0;
	for(i = 0; i < document.formSaisie.spyobjectname.length; i++){
		if(document.formSaisie.spyobjectname[i].checked)
		{
			Action = document.formSaisie.spyobjectname[i].value;
		}
	}
	if(Action == 0)
	{
		error = 121;
	}
	return error;
}

function noneVerification()
{
	var What = "";
	for(i = 0; i < document.formSaisie.typeofachievement.length; i++){
		if(document.formSaisie.typeofachievement[i].checked)
		{
			What = document.formSaisie.typeofachievement[i].value;
		}
	}
	var error = 0;
	if(What == "")
	{
		error = 100;
	}
	if(What == "none")
	{
		error = 101;
	}
	return error;
}